import { FC } from 'react'
import { Card } from 'antd'
import { useNews } from '@/hooks/dashboard'
import View from '@/components/View'

const News: FC = () => {
  const { loading, newsData } = useNews()

  return (
    <View className="app-news">
      {newsData.map(({ categoryId, categoryName, news }) => {
        return (
          <Card key={categoryId} className="news-box" title={categoryName} loading={loading} hoverable>
            {news.map(({ id, title, linkUrl }) => {
              return <a className="news-link" key={id} href={linkUrl} target="_blank" rel="noreferrer">{title}</a>
            })}
          </Card>
        )
      })}
    </View>
  )
}

export default News
